package com.proposition.exam.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.proposition.commons.exam.enums.ExamFieldEnum;
import com.proposition.commons.exam.exception.ExamException;
import com.proposition.commons.exam.exception.ExamImportException;
import com.proposition.commons.exam.result.Result;
import com.proposition.commons.exam.result.ResultEnum;
import com.proposition.commons.exam.result.ResultUtil;
import com.proposition.commons.exam.util.ExamFieldVolidateUtil;
import com.proposition.commons.exam.util.ExamImportUtil;
import com.proposition.commons.exam.util.ExamUtil;
import com.proposition.commons.exam.util.Util;
import com.proposition.commons.model.*;
import com.proposition.exam.service.*;
import com.proposition.support.security.CurrentUser;
import com.proposition.support.utils.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 16:03 2017/11/27
 * @description:
 */
@Service
@Transactional
public class IServiceExamImportImpl implements IServiceExamImport {
    @Autowired
    private ExamAcupointService examAcupointService;
    @Autowired
    private ExamAcupointOriginalService examAcupointOriginalService;
    @Autowired
    private ExamAnswer10Service examAnswer10Service;
    @Autowired
    private ExamAnswer10OriginalService examAnswer10OriginalService;
    @Autowired
    private ExamAnswer30Service examAnswer30Service;
    @Autowired
    private ExamAnswer30OriginalService examAnswer30OriginalService;
    @Autowired
    private ExamAcupointAdultService examAcupointAdultService;
    @Autowired
    private ExamAcupointAdultOriginalService examAcupointAdultOriginalService;
    @Autowired
    private ExamAcupointPediatricService examAcupointPediatricService;
    @Autowired
    private ExamAcupointPediatricOriginalService examAcupointPediatricOriginalService;

    private String examNum;
    private String[] fieldArray;

    @Override
    public Result importExamAcupoint(String filePath, Integer categoryId) {
        boolean intoNextExam = false;
        boolean examOnlyExist = true;
        boolean templateChange = false;
        Set<String> examNumSet = new HashSet<>();
        Set<String> examNumAlreadyExistSet = new HashSet<>();
        StringBuilder errorMsg = new StringBuilder();
        ExamException examException = null;
        List<Map<String, String>> exams = ExamImportUtil.parseUploadFileByWord2007(filePath, categoryId);

        //获取最大分数
        ExamParamWendaAcupoint examParam = new ExamParamWendaAcupoint();
        examParam = examParam.selectOne(new EntityWrapper());
        List<ExamAcupoint> examList = new ArrayList<>();
        List<ExamAcupointOriginal> examOriginalList = new ArrayList<>();

        List<String> stemList = new ArrayList<>();
        fieldArray = ExamFieldEnum.EXAM_ACUPOINT.getFieldArray();
        for (Map<String, String> examMap : exams) {
            Float totalScore = 0.0f;

            //实例化一个试题对象
            ExamAcupoint exam = new ExamAcupoint();
            exam.setId(com.proposition.support.utils.UUIDUtil.getExamUUIDByCategory("01"));
            exam.setUserIdImport(CurrentUser.INSTANCE.getUserId());
            exam.setCategoryId(categoryId);
            ALL:
            for (String field : fieldArray) {
                String getFieldValueFromTables = examMap.get(field);
                //不包含主治,每项不可为空
                switch (field) {
                    case "题号":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            intoNextExam = true;
                            examOnlyExist = false;
                            errorMsg.append("试题模板被修改，缺少【" + field + "】字段！<br>");
                            break ALL;
                        }
                        //验证题号
                        examException = Util.isLegalExamNum(getFieldValueFromTables);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        //验证试题题号重复性
                        if (!examNumAlreadyExistSet.contains(getFieldValueFromTables)) {
                            if (examNumSet.contains(getFieldValueFromTables)) {
                                examOnlyExist = false;
                                errorMsg.append("题号【" + examNum + "】多次重复出现，请修改！<br>");
                                examNumAlreadyExistSet.add(getFieldValueFromTables);
                            }
                        }
                        examNumSet.add(getFieldValueFromTables);
                        examNum = getFieldValueFromTables;

                        break;
                    case "题干":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        getFieldValueFromTables = ExamFieldVolidateUtil.getIllegalStem(getFieldValueFromTables);
                        examException = ExamFieldVolidateUtil.isIllegalField("题干", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            A:
                            for (String stem : stemList) {
                                if (stem.equals(getFieldValueFromTables)) {
                                    examOnlyExist = false;
                                    examException = new ExamImportException(examNum, ResultEnum.IMPORT_REPEAT_STEM);
                                    errorMsg.append(examException.getMessage() + "<br>");
                                    break A;
                                }
                            }
                            stemList.add(getFieldValueFromTables);

                            //判断题干是否存在
                            ExamAcupoint examAcupoint = exam.selectOne(new EntityWrapper<ExamAcupoint>().eq("stem", getFieldValueFromTables));
                            if (examAcupoint != null) {
                                intoNextExam = true;
                                examException = new ExamImportException(examNum, ResultEnum.ILLEGAL_STEM_EXIST);
                                errorMsg.append(examException.getMessage() + "<br>");
                                break ALL;
                            } else {
                                exam.setStem(getFieldValueFromTables);
                            }
                        }
                        break;
                    case "大纲代码":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamUtil.volidateOutlineCode(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setOutlineCode(getFieldValueFromTables);
                        }
                        break;
                    case "知识点":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamFieldVolidateUtil.isIllegalField("知识点", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setKnowledgePoint(getFieldValueFromTables);
                        }
                        break;
                    case "认知层次":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalCognitiveLevel(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setCognitiveLevel(getFieldValueFromTables);
                        }
                        break;
                    case "定位（1）":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("定位（1）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setLocation1(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float location1Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setLocation1Score(location1Score);
                            totalScore = totalScore + location1Score;
                        }
                        break;
                    case "定位（2）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("定位（2）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setLocation2(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float location2Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setLocation2Score(location2Score);
                                totalScore = totalScore + location2Score;
                            }
                        }
                        break;
                    case "定位（3）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("定位（3）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setLocation3(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float location3Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setLocation3Score(location3Score);
                                totalScore = totalScore + location3Score;
                            }
                        }
                        break;
                    case "归经":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("归经", getFieldValueFromTables, examNum, examParam.getMaxMeridianScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setMeridian(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float meridianScore = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setMeridianScore(meridianScore);
                            totalScore = totalScore + meridianScore;
                        }
                        break;
                    case "主治（1）":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("主治（1）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                        if (examException != null) {
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setMayorCure1(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float mayorCure1Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setMayorCure1Score(mayorCure1Score);
                            totalScore = totalScore + mayorCure1Score;
                        }
                        break;
                    case "主治（2）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（2）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure2(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure2Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure2Score(mayorCure2Score);
                                totalScore = totalScore + mayorCure2Score;
                            }
                        }
                        break;
                    case "主治（3）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（3）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure3(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure3Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure3Score(mayorCure3Score);
                                totalScore = totalScore + mayorCure3Score;
                            }
                        }
                        break;
                    case "主治（4）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（4）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure4(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure4Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure4Score(mayorCure4Score);
                                totalScore = totalScore + mayorCure4Score;
                            }
                        }
                        break;
                    case "主治（5）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（5）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure5(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure5Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure5Score(mayorCure5Score);
                                totalScore = totalScore + mayorCure5Score;
                            }
                        }
                        break;
                    case "主治（6）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（6）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure6(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure6Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure6Score(mayorCure6Score);
                                totalScore = totalScore + mayorCure6Score;
                            }
                        }
                        break;
                    case "主治（7）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（7）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure7(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure7Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure7Score(mayorCure7Score);
                                totalScore = totalScore + mayorCure7Score;
                            }
                        }
                        break;
                    case "主治（8）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("主治（8）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setMayorCure8(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float mayorCure8Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setMayorCure8Score(mayorCure8Score);
                                totalScore = totalScore + mayorCure8Score;
                            }
                        }
                        break;
                    default:
                        examOnlyExist = false;
                        errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_FIELD).getMessage() + "<br>");
                }
            }
            if (intoNextExam) {
                continue;
            }
            //验证总分
            if (totalScore>examParam.getMaxTotalScore()) {
                examOnlyExist = false;
                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_TOTAL_SCORE).getMessage() + "<br>");
            }
            exam.setTotalScore(totalScore);
            examList.add(exam);

            ExamAcupointOriginal examOriginal = new ExamAcupointOriginal();
            examOriginal = ExamImportUtil.setValueIntoExamOriginal(exam, examOriginal);
            examOriginalList.add(examOriginal);
        }
        if (errorMsg.toString().trim().length() != 0 && examOnlyExist && examList.size() > 0) {
            examAcupointService.insertBatch(examList);
            examAcupointOriginalService.insertBatch(examOriginalList);
            return ResultUtil.error(-1, errorMsg.toString());
        }

        if (errorMsg.toString().trim().length() == 0 && examList.size() > 0) {
            examAcupointService.insertBatch(examList);
            examAcupointOriginalService.insertBatch(examOriginalList);
            return ResultUtil.sucess();
        } else {
            throw new ExamException(ResultUtil.error(-1, errorMsg.toString()));
        }
    }

    @Override
    public Result importExamAnswer10(String filePath, Integer categoryId) {
        boolean intoNextExam = false;
        boolean examOnlyExist = true;
        boolean templateChange = false;
        Set<String> examNumSet = new HashSet<>();
        Set<String> examNumAlreadyExistSet = new HashSet<>();
        StringBuilder errorMsg = new StringBuilder();
        List<Map<String, String>> exams = ExamImportUtil.parseUploadFileByWord2007(filePath, categoryId);
        ExamException examException = null;
        float maxAnswerScore = 0;
        float maxTotalScore = 0;
        //获取最大分数
        if (categoryId == 2 || categoryId == 3 || categoryId == 4 || categoryId == 5 || categoryId == 6) {
            ExamParamWendaFSENC examParam = new ExamParamWendaFSENC();
            examParam = examParam.selectOne(new EntityWrapper());
            maxAnswerScore = examParam.getMaxAnswerScore();
            maxTotalScore=examParam.getMaxTotalScore();
        } else if (categoryId == 9 || categoryId == 10 || categoryId == 11) {
            ExamParamSinglePloyCEC examParam = new ExamParamSinglePloyCEC();
            examParam = examParam.selectOne(new EntityWrapper());
            maxAnswerScore = examParam.getMaxAnswerScore();
            maxTotalScore=examParam.getMaxTotalScore();
        }
        List<ExamAnswer10> examList = new ArrayList<>();
        List<ExamAnswer10Original> examOriginalList = new ArrayList<>();

        List<String> stemList = new ArrayList<>();
        fieldArray = ExamFieldEnum.EXAM_ANSWER10.getFieldArray();
        for (Map<String, String> examMap : exams) {
            Float totalScore = 0f;
            //实例化一个试题对象
            ExamAnswer10 exam = new ExamAnswer10();
            String categoryStr = ExamUtil.getCategoryStr(categoryId);
            exam.setId(UUIDUtil.getExamUUIDByCategory(categoryStr));
            exam.setUserIdImport(CurrentUser.INSTANCE.getUserId());
            exam.setCategoryId(categoryId);
            ALL:
            for (String field : fieldArray) {
                String getFieldValueFromTables = examMap.get(field);
                //不包含主治,每项不可为空
                switch (field) {
                    case "题号":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("试题模板被修改，缺少【" + field + "】字段！<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        //验证题号
                        examException = Util.isLegalExamNum(getFieldValueFromTables);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        if (!examNumAlreadyExistSet.contains(getFieldValueFromTables)) {
                            if (examNumSet.contains(getFieldValueFromTables)) {
                                examOnlyExist = false;
                                errorMsg.append("题号【" + examNum + "】多次重复出现，请修改！<br>");
                                examNumAlreadyExistSet.add(getFieldValueFromTables);
                            }
                        }
                        examNumSet.add(getFieldValueFromTables);
                        examNum = getFieldValueFromTables;
                        break;
                    case "手法类型":
                        if (categoryId == 9 || categoryId == 10) {
                            templateChange = Util.validateTemplateIsChange(examMap, field);
                            if (templateChange) {
                                examOnlyExist = false;
                                errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                                break;
                            }
                        }
                        if (categoryId == 10) {
                            Integer fiveCategoryId = ExamUtil.volidateSinglePloyFiveCategory(getFieldValueFromTables, examNum);
                            if (fiveCategoryId == null) {
                                examOnlyExist = false;
                                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_SINGLE_PLOY_SUBCLASS).getMessage() + "<br>");
                            } else {
                                exam.setSinglePloyFiveCategoryId(fiveCategoryId);
                            }
                        } else if (categoryId == 9) {
                            Integer examCategorySinglePloyPediatricSubclassId = ExamUtil.volidateSinglePloyPediatricSubclassId(getFieldValueFromTables, examNum);
                            if (examCategorySinglePloyPediatricSubclassId == null) {
                                examOnlyExist = false;
                                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_SINGLE_PLOY_SUBCLASS).getMessage() + "<br>");
                            } else {
                                exam.setExamCategorySinglePloyPediatricSubclassId(examCategorySinglePloyPediatricSubclassId);
                            }
                        }
                        break;
                    case "题干":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        getFieldValueFromTables = ExamFieldVolidateUtil.getIllegalStem(getFieldValueFromTables);
                        examException = ExamFieldVolidateUtil.isIllegalField("题干", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            A:
                            for (String stem : stemList) {
                                if (stem.equals(getFieldValueFromTables)) {
                                    examOnlyExist = false;
                                    examException = new ExamImportException(examNum, ResultEnum.IMPORT_REPEAT_STEM);
                                    errorMsg.append(examException.getMessage() + "<br>");
                                    break A;
                                }
                            }
                            stemList.add(getFieldValueFromTables);
                            //判断题干是否存在
                            ExamAnswer10 examAnswer10 = exam.selectOne(new EntityWrapper<ExamAcupoint>().eq("stem", getFieldValueFromTables).eq("category_id", categoryId));
                            if (examAnswer10 != null) {
                                examException = new ExamImportException(examNum, ResultEnum.ILLEGAL_STEM_EXIST);
                                errorMsg.append(examException.getMessage() + "<br>");
                                intoNextExam = true;
                                break ALL;
                            } else {
                                exam.setStem(getFieldValueFromTables);
                            }
                        }
                        break;
                    case "大纲代码":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamUtil.volidateOutlineCode(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setOutlineCode(getFieldValueFromTables);
                        }
                        break;
                    case "知识点":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamFieldVolidateUtil.isIllegalField("知识点", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setKnowledgePoint(getFieldValueFromTables);
                        }
                        break;
                    case "认知层次":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalCognitiveLevel(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setCognitiveLevel(getFieldValueFromTables);
                        }
                        break;
                    case "答案（1）":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("答案（1）", getFieldValueFromTables, examNum, maxAnswerScore);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setAnswer1(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float answer1Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setAnswer1Score(answer1Score);
                            totalScore = totalScore + answer1Score;
                        }
                        break;
                    case "答案（2）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（2）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer2(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer2Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer2Score(answer2Score);
                                totalScore = totalScore + answer2Score;
                            }
                        }
                        break;
                    case "答案（3）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（3）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer3(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer3Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer3Score(answer3Score);
                                totalScore = totalScore + answer3Score;
                            }
                        }
                        break;
                    case "答案（4）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（4）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer4(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer4Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer4Score(answer4Score);
                                totalScore = totalScore + answer4Score;
                            }
                        }
                        break;
                    case "答案（5）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（5）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer5(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer5Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer5Score(answer5Score);
                                totalScore = totalScore + answer5Score;
                            }
                        }
                        break;
                    case "答案（6）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（6）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer6(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer6Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer6Score(answer6Score);
                                totalScore = totalScore + answer6Score;
                            }
                        }
                        break;
                    case "答案（7）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（7）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer7(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer7Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer7Score(answer7Score);
                                totalScore = totalScore + answer7Score;
                            }
                        }
                        break;
                    case "答案（8）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（8）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer8(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer8Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer8Score(answer8Score);
                                totalScore = totalScore + answer8Score;
                            }
                        }
                        break;
                    case "答案（9）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（9）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer9(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer9Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer9Score(answer9Score);
                                totalScore = totalScore + answer9Score;
                            }
                        }
                        break;
                    case "答案（10）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（10）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer10(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer10Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer10Score(answer10Score);
                                totalScore = totalScore + answer10Score;
                            }
                        }
                        break;
                    default:
                        examOnlyExist = false;
                        errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_FIELD).getMessage() + "<br>");

                }
            }
            if (intoNextExam) {
                continue;
            }
            //验证总分
            if (totalScore>maxTotalScore) {
                examOnlyExist = false;
                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_TOTAL_SCORE).getMessage() + "<br>");
            }
            exam.setTotalScore(totalScore);
            examList.add(exam);

            ExamAnswer10Original examOriginal = new ExamAnswer10Original();
            examOriginal = ExamImportUtil.setValueIntoExamOriginal(exam, examOriginal);
            examOriginalList.add(examOriginal);
        }

        if (errorMsg.toString().trim().length() != 0 && examOnlyExist && examList.size() > 0) {
            examAnswer10Service.insertBatch(examList);
            examAnswer10OriginalService.insertBatch(examOriginalList);
            return ResultUtil.error(-1, errorMsg.toString());
        }

        if (errorMsg.toString().trim().length() == 0 && examList.size() > 0) {
            examAnswer10Service.insertBatch(examList);
            examAnswer10OriginalService.insertBatch(examOriginalList);
            return ResultUtil.sucess();
        } else {
            throw new ExamException(ResultUtil.error(-1, errorMsg.toString()));
        }
    }

    @Override
    public Result importExamAcupointAdult(String filePath, Integer categoryId) {
        boolean intoNextExam = false;
        boolean examOnlyExist = true;
        boolean templateChange = false;
        Set<String> examNumSet = new HashSet<>();
        Set<String> examNumAlreadyExistSet = new HashSet<>();
        StringBuilder errorMsg = new StringBuilder();
        ExamException examException = null;
        List<Map<String, String>> exams = ExamImportUtil.parseUploadFileByWord2007(filePath, categoryId);
        //获取最大分数
        ExamParamAcupointLocationAdult examParam = new ExamParamAcupointLocationAdult();
        examParam = examParam.selectOne(new EntityWrapper());
        List<ExamAcupointAdult> examList = new ArrayList<>();
        List<ExamAcupointAdultOriginal> examOriginalList = new ArrayList<>();

        List<String> stemList = new ArrayList<>();
        fieldArray = ExamFieldEnum.EXAM_ACUPOINT_ADULT.getFieldArray();
        for (Map<String, String> examMap : exams) {
            Float totalScore = 0f;

            //实例化一个试题对象
            ExamAcupointAdult exam = new ExamAcupointAdult();
            String categoryStr = ExamUtil.getCategoryStr(categoryId);
            exam.setId(UUIDUtil.getExamUUIDByCategory(categoryStr));
            exam.setUserIdImport(CurrentUser.INSTANCE.getUserId());
            exam.setCategoryId(categoryId);
            ALL:
            for (String field : fieldArray) {
                String getFieldValueFromTables = examMap.get(field);
                //不包含主治,每项不可为空
                switch (field) {
                    case "题号":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("试题模板被修改，缺少【" + field + "】字段！<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        //验证题号
                        examException = Util.isLegalExamNum(getFieldValueFromTables);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        if (!examNumAlreadyExistSet.contains(getFieldValueFromTables)) {
                            if (examNumSet.contains(getFieldValueFromTables)) {
                                examOnlyExist = false;
                                errorMsg.append("题号【" + examNum + "】多次重复出现，请修改！<br>");
                                examNumAlreadyExistSet.add(getFieldValueFromTables);
                            }
                        }
                        examNumSet.add(getFieldValueFromTables);
                        examNum = getFieldValueFromTables;
                        break;
                    case "题干":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        getFieldValueFromTables = ExamFieldVolidateUtil.getIllegalStem(getFieldValueFromTables);
                        examException = ExamFieldVolidateUtil.isIllegalField("题干", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            A:
                            for (String stem : stemList) {
                                if (stem.equals(getFieldValueFromTables)) {
                                    examOnlyExist = false;
                                    examException = new ExamImportException(examNum, ResultEnum.IMPORT_REPEAT_STEM);
                                    errorMsg.append(examException.getMessage() + "<br>");
                                    break A;
                                }
                            }
                            stemList.add(getFieldValueFromTables);
                            //判断题干是否存在
                            ExamAcupointAdult examAcupointAdult = exam.selectOne(new EntityWrapper<ExamAcupoint>().eq("stem", getFieldValueFromTables));
                            if (examAcupointAdult != null) {
                                examException = new ExamImportException(examNum, ResultEnum.ILLEGAL_STEM_EXIST);
                                errorMsg.append(examException.getMessage() + "<br>");
                                intoNextExam = true;
                                break ALL;
                            } else {
                                exam.setStem(getFieldValueFromTables);
                            }
                        }
                        break;
                    case "大纲代码":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamUtil.volidateOutlineCode(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setOutlineCode(getFieldValueFromTables);
                        }
                        break;
                    case "知识点":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamFieldVolidateUtil.isIllegalField("知识点", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setKnowledgePoint(getFieldValueFromTables);
                        }
                        break;
                    case "认知层次":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalCognitiveLevel(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setCognitiveLevel(getFieldValueFromTables);
                        }
                        break;
                    case "部位":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("部位", getFieldValueFromTables, examNum, examParam.getMaxPartScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            String partName = Util.getAnswerOrScore(0, getFieldValueFromTables);
                            ExamPart examPart = new ExamPart();
                            examPart = examPart.selectOne(new EntityWrapper().eq("part", partName));
                            if (examPart == null) {
                                examOnlyExist = false;
                                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_PART).getMessage() + "<br>");
                            } else {
                                exam.setPartIdAdult(examPart.getId());
                                Float partScore = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setPartScoreAdult(partScore);
                                totalScore = totalScore + partScore;
                            }
                        }
                        break;
                    case "归经":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("归经", getFieldValueFromTables, examNum, examParam.getMaxMeridianScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setMeridianAdult(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float meridianScoreAdult = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setMeridianScoreAdult(meridianScoreAdult);
                            totalScore = totalScore + meridianScoreAdult;
                        }
                        break;
                    case "定位（1）":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("定位（1）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setLocation1Adult(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float location1ScoreAdult = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setLocation1ScoreAdult(location1ScoreAdult);
                            totalScore = totalScore + location1ScoreAdult;
                        }
                        break;
                    case "定位（2）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("定位（2）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setLocation2Adult(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float location2ScoreAdult = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setLocation2ScoreAdult(location2ScoreAdult);
                                totalScore = totalScore + location2ScoreAdult;
                            }
                        }
                        break;
                    case "定位（3）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("定位（3）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setLocation3Adult(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float location3ScoreAdult = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setLocation3ScoreAdult(location3ScoreAdult);
                                totalScore = totalScore + location3ScoreAdult;
                            }
                        }
                        break;
                    default:
                        examOnlyExist = false;
                        errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_FIELD).getMessage() + "<br>");
                }
            }
            if (intoNextExam) {
                continue;
            }
            //验证总分
            if (totalScore>examParam.getMaxTotalScore()) {
                examOnlyExist = false;
                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_TOTAL_SCORE).getMessage() + "<br>");
            }
            exam.setTotalScore(totalScore);
            examList.add(exam);

            ExamAcupointAdultOriginal examOriginal = new ExamAcupointAdultOriginal();
            examOriginal = ExamImportUtil.setValueIntoExamOriginal(exam, examOriginal);
            examOriginalList.add(examOriginal);
        }
        if (errorMsg.toString().trim().length() != 0 && examOnlyExist && examList.size() > 0) {
            examAcupointAdultService.insertBatch(examList);
            examAcupointAdultOriginalService.insertBatch(examOriginalList);
            return ResultUtil.error(-1, errorMsg.toString());
        }

        if (errorMsg.toString().trim().length() == 0 && examList.size() > 0) {
            examAcupointAdultService.insertBatch(examList);
            examAcupointAdultOriginalService.insertBatch(examOriginalList);
            return ResultUtil.sucess();
        } else {
            throw new ExamException(ResultUtil.error(-1, errorMsg.toString()));
        }
    }

    @Override
    public Result importExamAcupointPediatric(String filePath, Integer categoryId) {
        boolean intoNextExam = false;
        boolean examOnlyExist = true;
        boolean templateChange = false;
        Set<String> examNumSet = new HashSet<>();
        Set<String> examNumAlreadyExistSet = new HashSet<>();
        StringBuilder errorMsg = new StringBuilder();
        List<Map<String, String>> exams = ExamImportUtil.parseUploadFileByWord2007(filePath, categoryId);
        ExamException examException = null;
        //获取最大分数
        ExamParamAcupointLocationPediatric examParam = new ExamParamAcupointLocationPediatric();
        examParam = examParam.selectOne(new EntityWrapper());
        List<ExamAcupointPediatric> examList = new ArrayList<>();
        List<ExamAcupointPediatricOriginal> examOriginalList = new ArrayList<>();

        List<String> stemList = new ArrayList<>();
        fieldArray = ExamFieldEnum.EXAM_ACUPOINT_PEDIATRIC.getFieldArray();
        for (Map<String, String> examMap : exams) {
            Float totalScore = 0f;

            //实例化一个试题对象
            ExamAcupointPediatric exam = new ExamAcupointPediatric();
            String categoryStr = ExamUtil.getCategoryStr(categoryId);
            exam.setId(UUIDUtil.getExamUUIDByCategory(categoryStr));
            exam.setUserIdImport(CurrentUser.INSTANCE.getUserId());
            exam.setCategoryId(categoryId);
            ALL:
            for (String field : fieldArray) {
                String getFieldValueFromTables = examMap.get(field);
                //不包含主治,每项不可为空
                switch (field) {
                    case "题号":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("试题模板被修改，缺少【" + field + "】字段！<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        //验证题号
                        examException = Util.isLegalExamNum(getFieldValueFromTables);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        if (!examNumAlreadyExistSet.contains(getFieldValueFromTables)) {
                            if (examNumSet.contains(getFieldValueFromTables)) {
                                examOnlyExist = false;
                                errorMsg.append("题号【" + examNum + "】多次重复出现，请修改！<br>");
                                examNumAlreadyExistSet.add(getFieldValueFromTables);
                            }
                        }
                        examNumSet.add(getFieldValueFromTables);
                        examNum = getFieldValueFromTables;
                        break;
                    case "题干":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        getFieldValueFromTables = ExamFieldVolidateUtil.getIllegalStem(getFieldValueFromTables);
                        examException = ExamFieldVolidateUtil.isIllegalField("题干", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            A:
                            for (String stem : stemList) {
                                if (stem.equals(getFieldValueFromTables)) {
                                    examOnlyExist = false;
                                    examException = new ExamImportException(examNum, ResultEnum.IMPORT_REPEAT_STEM);
                                    errorMsg.append(examException.getMessage() + "<br>");
                                    break A;
                                }
                            }
                            stemList.add(getFieldValueFromTables);
                            //判断题干是否存在
                            ExamAcupointPediatric examAcupointPediatric = exam.selectOne(new EntityWrapper<ExamAcupoint>().eq("stem", getFieldValueFromTables));
                            if (examAcupointPediatric != null) {
                                examException = new ExamImportException(examNum, ResultEnum.ILLEGAL_STEM_EXIST);
                                errorMsg.append(examException.getMessage() + "<br>");
                                intoNextExam = true;
                                break ALL;
                            } else {
                                exam.setStem(getFieldValueFromTables);
                            }
                        }
                        break;
                    case "大纲代码":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamUtil.volidateOutlineCode(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setOutlineCode(getFieldValueFromTables);
                        }
                        break;
                    case "知识点":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamFieldVolidateUtil.isIllegalField("题干", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setKnowledgePoint(getFieldValueFromTables);
                        }
                        break;
                    case "认知层次":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalCognitiveLevel(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setCognitiveLevel(getFieldValueFromTables);
                        }
                        break;
                    case "部位":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("部位", getFieldValueFromTables, examNum, examParam.getMaxPartScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            String partName = Util.getAnswerOrScore(0, getFieldValueFromTables);
                            ExamPart examPart = new ExamPart();
                            examPart = examPart.selectOne(new EntityWrapper().eq("part", partName));
                            if (examPart == null) {
                                examOnlyExist = false;
                                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_PART).getMessage() + "<br>");
                            } else {
                                exam.setPartIdPediatric(examPart.getId());
                                Float partScorePediatric = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setPartScorePediatric(partScorePediatric);
                                totalScore = totalScore + partScorePediatric;
                            }
                        }
                        break;
                    case "具体部位":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("具体部位", getFieldValueFromTables, examNum, examParam.getMaxPartDetailScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setPartDetailPediatric(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float partDetailScorePediatric = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setPartDetailScorePediatric(partDetailScorePediatric);
                            totalScore = totalScore + partDetailScorePediatric;
                        }
                        break;
                    case "定位（1）":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("定位（1）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setLocation1Pediatric(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float location1ScorePediatric = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setLocation1ScorePediatric(location1ScorePediatric);
                            totalScore = totalScore + location1ScorePediatric;
                        }
                        break;
                    case "定位（2）":
                        //先判断答案是否有内容
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("定位（2）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setLocation2Pediatric(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float location2ScorePediatric = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setLocation2ScorePediatric(location2ScorePediatric);
                                totalScore = totalScore + location2ScorePediatric;
                            }
                        }
                        break;
                    case "定位（3）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("定位（3）", getFieldValueFromTables, examNum, examParam.getMaxLocationScore());
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setLocation3Pediatric(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float location3ScorePediatric = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setLocation3ScorePediatric(location3ScorePediatric);
                                totalScore = totalScore + location3ScorePediatric;
                            }
                        }
                        break;
                    default:
                        examOnlyExist = false;
                        errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_FIELD).getMessage() + "<br>");

                }
            }
            if (intoNextExam) {
                continue;
            }
            if (totalScore>examParam.getMaxTotalScore()) {
                examOnlyExist = false;
                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_TOTAL_SCORE).getMessage() + "<br>");
            }
            exam.setTotalScore(totalScore);
            examList.add(exam);

            ExamAcupointPediatricOriginal examOriginal = new ExamAcupointPediatricOriginal();
            examOriginal = ExamImportUtil.setValueIntoExamOriginal(exam, examOriginal);
            examOriginalList.add(examOriginal);
        }
        if (errorMsg.toString().trim().length() != 0 && examOnlyExist && examList.size() > 0) {
            examAcupointPediatricService.insertBatch(examList);
            examAcupointPediatricOriginalService.insertBatch(examOriginalList);
            return ResultUtil.error(-1, errorMsg.toString());
        }

        if (errorMsg.toString().trim().length() == 0 && examList.size() > 0) {
            examAcupointPediatricService.insertBatch(examList);
            examAcupointPediatricOriginalService.insertBatch(examOriginalList);
            return ResultUtil.sucess();
        } else {
            throw new ExamException(ResultUtil.error(-1, errorMsg.toString()));
        }
    }

    @Override
    public Result importExamAnswer30(String filePath, Integer categoryId) {
        boolean intoNextExam = false;
        boolean examOnlyExist = true;
        boolean templateChange = false;
        Set<String> examNumSet = new HashSet<>();
        Set<String> examNumAlreadyExistSet = new HashSet<>();
        StringBuilder errorMsg = new StringBuilder();
        ExamException examException = null;
        List<Map<String, String>> exams = ExamImportUtil.parseUploadFileByWord2007(filePath, categoryId);
        //获取最大分数
        float maxAnswerScore = 0f;
        ExamParamCompletePloyFSEN examParam = new ExamParamCompletePloyFSEN();
        examParam = examParam.selectOne(new EntityWrapper());
        maxAnswerScore = examParam.getMaxAnswerScore();

        List<ExamAnswer30> examList = new ArrayList<>();
        List<ExamAnswer30Original> examOriginalList = new ArrayList<>();
        List<String> stemList = new ArrayList<>();
        fieldArray = ExamFieldEnum.EXAM_ANSWER30.getFieldArray();
        for (Map<String, String> examMap : exams) {
            Float totalScore = 0f;

            //实例化一个试题对象
            ExamAnswer30 exam = new ExamAnswer30();
            String categoryStr = ExamUtil.getCategoryStr(categoryId);
            exam.setId(UUIDUtil.getExamUUIDByCategory(categoryStr));
            exam.setUserIdImport(CurrentUser.INSTANCE.getUserId());
            exam.setCategoryId(categoryId);
            ALL:
            for (String field : fieldArray) {
                String getFieldValueFromTables = examMap.get(field);
                switch (field) {
                    case "题号":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("试题模板被修改，缺少【" + field + "】字段！<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        //验证题号
                        examException = Util.isLegalExamNum(getFieldValueFromTables);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                            intoNextExam = true;
                            break ALL;
                        }
                        if (!examNumAlreadyExistSet.contains(getFieldValueFromTables)) {
                            if (examNumSet.contains(getFieldValueFromTables)) {
                                examOnlyExist = false;
                                errorMsg.append("题号【" + examNum + "】多次重复出现，请修改！<br>");
                                examNumAlreadyExistSet.add(getFieldValueFromTables);
                            }
                        }
                        examNumSet.add(getFieldValueFromTables);
                        examNum = getFieldValueFromTables;
                        break;
                    case "题干":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        getFieldValueFromTables = ExamFieldVolidateUtil.getIllegalStem(getFieldValueFromTables);
                        examException = ExamFieldVolidateUtil.isIllegalField("题干", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            A:
                            for (String stem : stemList) {
                                if (stem.equals(getFieldValueFromTables)) {
                                    examOnlyExist = false;
                                    examException = new ExamImportException(examNum, ResultEnum.IMPORT_REPEAT_STEM);
                                    errorMsg.append(examException.getMessage() + "<br>");
                                    break A;
                                }
                            }
                            stemList.add(getFieldValueFromTables);
                            ExamAnswer30 examAnswer30 = exam.selectOne(new EntityWrapper<ExamAcupoint>().eq("stem", getFieldValueFromTables).eq("category_id", categoryId));
                            if (examAnswer30 != null) {
                                examException = new ExamImportException(examNum, ResultEnum.ILLEGAL_STEM_EXIST);
                                errorMsg.append(examException.getMessage() + "<br>");
                                intoNextExam = true;
                                break ALL;
                            } else {
                                exam.setStem(getFieldValueFromTables);
                            }
                        }
                        break;
                    case "大纲代码":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamUtil.volidateOutlineCode(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setOutlineCode(getFieldValueFromTables);
                        }
                        break;
                    case "知识点":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = ExamFieldVolidateUtil.isIllegalField("知识点", getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setKnowledgePoint(getFieldValueFromTables);
                        }
                        break;
                    case "认知层次":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalCognitiveLevel(getFieldValueFromTables, examNum);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setCognitiveLevel(getFieldValueFromTables);
                        }
                        break;
                    case "答案（1）":
                        templateChange = Util.validateTemplateIsChange(examMap, field);
                        if (templateChange) {
                            examOnlyExist = false;
                            errorMsg.append("第【" + examNum + "】题，试题模板被修改，缺少【" + field + "】字段！<br>");
                            break;
                        }
                        examException = Util.isLegalAnswerWithScore("答案（1）", getFieldValueFromTables, examNum, maxAnswerScore);
                        if (examException != null) {
                            examOnlyExist = false;
                            errorMsg.append(examException.getMessage() + "<br>");
                        } else {
                            exam.setAnswer1(Util.getAnswerOrScore(0, getFieldValueFromTables));
                            Float answer1Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                            exam.setAnswer1Score(answer1Score);
                            totalScore = totalScore + answer1Score;
                        }
                        break;
                    case "答案（2）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（2）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer2(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer2Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer2Score(answer2Score);
                                totalScore = totalScore + answer2Score;
                            }
                        }
                        break;
                    case "答案（3）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（3）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer3(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer3Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer3Score(answer3Score);
                                totalScore = totalScore + answer3Score;
                            }
                        }
                        break;
                    case "答案（4）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（4）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer4(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer4Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer4Score(answer4Score);
                                totalScore = totalScore + answer4Score;
                            }
                        }
                        break;
                    case "答案（5）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（5）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer5(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer5Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer5Score(answer5Score);
                                totalScore = totalScore + answer5Score;
                            }
                        }
                        break;
                    case "答案（6）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（6）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer6(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer6Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer6Score(answer6Score);
                                totalScore = totalScore + answer6Score;
                            }
                        }
                        break;
                    case "答案（7）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（7）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer7(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer7Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer7Score(answer7Score);
                                totalScore = totalScore + answer7Score;
                            }
                        }
                        break;
                    case "答案（8）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（8）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer8(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer8Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer8Score(answer8Score);
                                totalScore = totalScore + answer8Score;
                            }
                        }
                        break;
                    case "答案（9）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（9）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer9(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer9Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer9Score(answer9Score);
                                totalScore = totalScore + answer9Score;
                            }
                        }
                        break;
                    case "答案（10）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（10）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer10(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer10Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer10Score(answer10Score);
                                totalScore = totalScore + answer10Score;
                            }
                        }
                        break;
                    case "答案（11）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（11）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer11(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer11Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer11Score(answer11Score);
                                totalScore = totalScore + answer11Score;
                            }
                        }
                        break;
                    case "答案（12）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（12）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer12(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer12Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer12Score(answer12Score);
                                totalScore = totalScore + answer12Score;
                            }
                        }
                        break;
                    case "答案（13）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（13）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer13(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer13Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer13Score(answer13Score);
                                totalScore = totalScore + answer13Score;
                            }
                        }
                        break;
                    case "答案（14）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（14）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer14(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer14Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer14Score(answer14Score);
                                totalScore = totalScore + answer14Score;
                            }
                        }
                        break;
                    case "答案（15）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（15）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer15(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer15Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer15Score(answer15Score);
                                totalScore = totalScore + answer15Score;
                            }
                        }
                        break;
                    case "答案（16）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（16）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer16(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer16Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer16Score(answer16Score);
                                totalScore = totalScore + answer16Score;
                            }
                        }
                        break;
                    case "答案（17）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（17）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer17(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer17Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer17Score(answer17Score);
                                totalScore = totalScore + answer17Score;
                            }
                        }
                        break;
                    case "答案（18）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（18）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer18(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer18Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer18Score(answer18Score);
                                totalScore = totalScore + answer18Score;
                            }
                        }
                        break;
                    case "答案（19）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（19）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer19(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer19Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer19Score(answer19Score);
                                totalScore = totalScore + answer19Score;
                            }
                        }
                        break;
                    case "答案（20）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（20）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer20(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer20Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer20Score(answer20Score);
                                totalScore = totalScore + answer20Score;
                            }
                        }
                        break;
                    case "答案（21）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（21）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer21(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer21Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer21Score(answer21Score);
                                totalScore = totalScore + answer21Score;
                            }
                        }
                        break;
                    case "答案（22）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（22）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer22(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer22Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer22Score(answer22Score);
                                totalScore = totalScore + answer22Score;
                            }
                        }
                        break;
                    case "答案（23）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（23）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer23(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer23Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer23Score(answer23Score);
                                totalScore = totalScore + answer23Score;
                            }
                        }
                        break;
                    case "答案（24）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（24）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer24(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer24Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer24Score(answer24Score);
                                totalScore = totalScore + answer24Score;
                            }
                        }
                        break;
                    case "答案（25）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（25）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer25(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer25Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer25Score(answer25Score);
                                totalScore = totalScore + answer25Score;
                            }
                        }
                        break;
                    case "答案（26）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（26）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer26(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer26Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer26Score(answer26Score);
                                totalScore = totalScore + answer26Score;
                            }
                        }
                        break;
                    case "答案（27）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（27）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer27(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer27Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer27Score(answer27Score);
                                totalScore = totalScore + answer27Score;
                            }
                        }
                        break;
                    case "答案（28）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（28）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer28(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer28Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer28Score(answer28Score);
                                totalScore = totalScore + answer28Score;
                            }
                        }
                        break;
                    case "答案（29）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（29）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer29(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer29Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer29Score(answer29Score);
                                totalScore = totalScore + answer29Score;
                            }
                        }
                        break;
                    case "答案（30）":
                        if (getFieldValueFromTables != null && getFieldValueFromTables.length() != 0) {
                            examException = Util.isLegalAnswerWithScore("答案（30）", getFieldValueFromTables, examNum, maxAnswerScore);
                            if (examException != null) {
                                examOnlyExist = false;
                                errorMsg.append(examException.getMessage() + "<br>");
                            } else {
                                exam.setAnswer30(Util.getAnswerOrScore(0, getFieldValueFromTables));
                                Float answer30Score = Float.valueOf(Util.getAnswerOrScore(1, getFieldValueFromTables));
                                exam.setAnswer30Score(answer30Score);
                                totalScore = totalScore + answer30Score;
                            }
                        }
                        break;
                    default:
                        examOnlyExist = false;
                        errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_FIELD).getMessage() + "<br>");
                }
            }
            if (intoNextExam) {
                continue;
            }
            if (totalScore>examParam.getMaxTotalScore()) {
                examOnlyExist = false;
                errorMsg.append(new ExamImportException(examNum, ResultEnum.ILLEGAL_TOTAL_SCORE).getMessage() + "<br>");
            }
            exam.setTotalScore(totalScore);
            examList.add(exam);

            ExamAnswer30Original examOriginal = new ExamAnswer30Original();
            examOriginal = ExamImportUtil.setValueIntoExamOriginal(exam, examOriginal);
            examOriginalList.add(examOriginal);
        }
        if (errorMsg.toString().trim().length() != 0 && examOnlyExist && examList.size() > 0) {
            examAnswer30Service.insertBatch(examList);
            examAnswer30OriginalService.insertBatch(examOriginalList);
            return ResultUtil.error(-1, errorMsg.toString());
        }

        if (errorMsg.toString().trim().length() == 0 && examList.size() > 0) {
            examAnswer30Service.insertBatch(examList);
            examAnswer30OriginalService.insertBatch(examOriginalList);
            return ResultUtil.sucess();
        } else {
            throw new ExamException(ResultUtil.error(-1, errorMsg.toString()));
        }
    }
}
